#import "MainView.h"
#import "HomeView.h"

@implementation MainView

mainInt = 0;

- (IBAction)view2 {
    [self addSubview:homeView];
}

- (IBAction)startTimer {
	paused = NO;
	if(timer != nil) {
	[timer invalidate];
	}
	timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/1.0) target:self selector:@selector (updateLabel) userInfo:nil repeats:YES];
	
}

- (void)updateLabel {
	if (paused == YES) {
		return;
	}
	if (paused == NO) {
	mainInt += 1;
	stopwatchLabel.text = [NSString stringWithFormat:@"%d", mainInt];
	}
}

- (IBAction)togglePause {
	if (paused == NO) {
		paused = YES;
	}
}

- (IBAction)resetTimer {
	[timer invalidate];
	timer = nil;
	paused = YES;
	mainInt = 0;
	stopwatchLabel.text = [NSString stringWithFormat:@"%d", mainInt];
}
	
@end
